<script>
import {Setting,ArrowDown,Fold} from "@element-plus/icons-vue"
export default {
  name: "Header",
  components:{
    Setting,
    ArrowDown,
    Fold
  },
  props: {
    isCollapse: {
      type: Boolean,
      default: false
    }
  },
  methods:{
    toUser(){
      console.log("俺不中了")
    },
    logout(){
      console.log("logout")
    },
    toggleCollapse() {
      this.$emit('toggle-collapse');
    }
  },
  data() {
    return {
      activeIndex: '1'
    }
  }

}
</script>

<template>
  <div class="header-toolbar">
    <div class="collapse-btn" @click="toggleCollapse">
      <el-icon class="collapse-icon" :class="{ 'rotated': isCollapse }">
        <Fold />
      </el-icon>
    </div>
    
    <div class="header-title">
      <span class="title-text">欢迎来到仓库管理系统</span>
    </div>
    
    <div class="user-section">
      <span class="username">胡xx</span>
      <el-dropdown class="user-dropdown">
        <el-icon class="dropdown-icon">
          <ArrowDown />
        </el-icon>
        <template #dropdown>
          <el-dropdown-menu class="user-menu">
            <el-dropdown-item @click="toUser" class="menu-item">
              <el-icon><Setting /></el-icon>
              个人资料
            </el-dropdown-item>
            <el-dropdown-item @click="logout" class="menu-item logout-item">
              <el-icon><ArrowDown /></el-icon>
              退出登录
            </el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<style scoped>
.header-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  padding: 0 20px;
}

.collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(64, 158, 255, 0.1);
  cursor: pointer;
  transition: all 0.3s ease;
}

.collapse-btn:hover {
  background: rgba(64, 158, 255, 0.2);
  transform: scale(1.05);
}

.collapse-icon {
  font-size: 18px;
  color: #409EFF;
  transition: transform 0.3s ease;
}

.collapse-icon.rotated {
  transform: rotate(180deg);
}

.header-title {
  flex: 1;
  text-align: center;
}

.title-text {
  font-size: 24px;
  font-weight: 600;
  background: linear-gradient(135deg, #409EFF, #67C23A);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

.user-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.username {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  padding: 8px 16px;
  background: rgba(64, 158, 255, 0.1);
  border-radius: 20px;
  border: 1px solid rgba(64, 158, 255, 0.2);
}

.user-dropdown {
  cursor: pointer;
}

.dropdown-icon {
  font-size: 16px;
  color: #666;
  transition: all 0.3s ease;
}

.user-dropdown:hover .dropdown-icon {
  color: #409EFF;
  transform: translateY(-1px);
}

/* 下拉菜单样式 */
:deep(.user-menu) {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  margin-top: 8px;
  padding: 8px 0;
}

:deep(.menu-item) {
  padding: 12px 20px;
  color: #333;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

:deep(.menu-item:hover) {
  background: rgba(64, 158, 255, 0.1);
  color: #409EFF;
}

:deep(.logout-item:hover) {
  background: rgba(245, 108, 108, 0.1);
  color: #F56C6C;
}

:deep(.menu-item .el-icon) {
  font-size: 16px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .header-toolbar {
    padding: 0 15px;
  }
  
  .title-text {
    font-size: 18px;
  }
  
  .username {
    font-size: 14px;
    padding: 6px 12px;
  }
  
  .collapse-btn {
    width: 35px;
    height: 35px;
  }
  
  .collapse-icon {
    font-size: 16px;
  }
}
</style>